/** CS2340 40 Jiggawatt Hard Driver Project
 *  Suk Hwan Hong
 *  Rhys Saraceni
 *  Travis Cooper
 *  Luke Stubb
 */

// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, numericLiterals
package edu.gatech.jiggawatt.office.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */
public class User implements Serializable {
	
	/**
	 * Field id.
	 */
	private String id;
	
	/**
	 * Field password.
	 */
	private String password;
	
	/**
	 * Field userType.
	 */
	private int userType; // Admin = 0, Patient = 1, Nurse = 2, Doctor = 3
	
	/**
	 * Field firstName.
	 */
	private String firstName;
	
	/**
	 * Field lastName.
	 */
	private String lastName;
	
	/**
	 * Field age.
	 */
	private int age;
	
	/**
	 * Field gender.
	 */
	private int gender;
	
	/**
	 * Field address.
	 */
	private String address;
	
	/**
	 * Field phone.
	 */
	private String phone;
	
	/**
	 * Field email.
	 */
	private String email;
	
	/**
	 * Field newMessage.
	 */
	private boolean newMessage;
	
	/**
	 * Field messages.
	 */
	private List<String> messages = new ArrayList<String>(); // $codepro.audit.disable variableShouldBeFinal
	
	/**
	 * Field failedLogin.
	 */
	private int failedLogin = 0;
	
	/**
	 * Field suspended.
	 */
	private boolean suspended = false;
	
	/**
	 * Constructor for User.
	 * @param id String
	 * @param pw String
	 * @param firstName String
	 * @param lastName String
	 * @param userType int
	 */
	public User(String id, String pw, String firstName, String lastName, int userType) {
		this.id = id;
		this.password = pw;
		this.firstName = firstName;
		this.lastName = lastName;
		this.userType = userType;
	}

	/**
	 * Method setId.
	 * @param id String
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * Method getId.
	 * @return String
	 */
	public String getId() {
		return id;
	}
	
	/**
	 * Method setUserType.
	 * @param userType int
	 */
	public void setUserType(int userType) {
		this.userType = userType;
	}

	/**
	 * Method getUserType.
	 * @return int
	 */
	public int getUserType() {
		return userType;
	}

	/**
	 * Method setFirstName.
	 * @param firstName String
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	/**
	 * Method setLastName.
	 * @param lastName String
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	/**
	 * Method getFirstName.
	 * @return String
	 */
	public String getFirstName() {
		return firstName;
	}
	
	/**
	 * Method getLastName.
	 * @return String
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * Method getFullName.
	 * @return String
	 */
	public String getFullName() {
		return firstName + " " + lastName;
	}
	
	/**
	 * Method setAge.
	 * @param age int
	 */
	public void setAge(int age) {
		this.age = age;
	}

	/**
	 * Method getAge.
	 * @return int
	 */
	public int getAge() {
		return age;
	}

	/**
	 * Method setGender.
	 * @param gender int
	 */
	public void setGender(int gender) {
		this.gender = gender;
	}

	/**
	 * Method getGender.
	 * @return int
	 */
	public int getGender() {
		return gender;
	}

	/**
	 * Method setAddress.
	 * @param address String
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * Method getAddress.
	 * @return String
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * Method setPhone.
	 * @param phone String
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * Method getPhone.
	 * @return String
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * Method setEmail.
	 * @param email String
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * Method getEmail.
	 * @return String
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * Method setNewMessage.
	 * @param newMessage boolean
	 */
	public void setNewMessage(boolean newMessage) {
		this.newMessage = newMessage;
	}

	/**
	 * Method isNewMessage.
	 * @return boolean
	 */
	public boolean isNewMessage() {
		return newMessage;
	}

	/**
	 * reset login attempt counter to 0
	 */
	public void clearFailedLogin(){
		this.failedLogin = 0;
	}
	
	/**
	 * increment the login attempt counter
	 * the user is suspended once the failedLogin == 3
	 */
	public void incFailedLogin() {
		this.failedLogin++;
		if (this.failedLogin == 3) {
			suspended = true;
		}
	}

	/**
	 * Method getFailedLogin.
	 * @return int
	 */
	public int getFailedLogin() {
		return failedLogin;
	}

	/**
	 * Method suspend.
	 */
	public void suspend() {
		this.suspended = true;
	}
	
	/**
	 * Method unSuspend.
	 */
	public void unSuspend() {
		this.suspended = false;
	}

	/**
	 * Method isSuspended.
	 * @return boolean
	 */
	public boolean isSuspended() {
		return suspended;
	}
		
	//set Password for the user
	/**
	 * Method setPassword.
	 * @param password String
	 */
	public void setPassword(String password){
		this.password = password;
	}
	
	//check to see if the password is the same as expected
	/**
	 * Method checkPassword.
	 * @param password String
	 * @return boolean
	 */
	public boolean checkPassword(String password){ // $codepro.audit.disable booleanMethodNamingConvention
		return (this.password).equals(password);
	}
	
	/**
	 * Method addMessage.
	 * @param message String
	 */
	public void addMessage(String message){
		this.messages.add(message);
		this.setNewMessage(true);
	}
}